#include "md5_tokens.h"
#include "lexical_cast.h"

using namespace krryn::data;

namespace krryn{
namespace data{
	std::string tag_to_string(md5_tags a_Tag){
		if(false){}
		TAG(TO_STRING);
		return "";
	}
}
}

std::string md5_token::as_string(){
	expect(string);
	return std::string(m_String.begin() + 1, m_String.end() - 1);
}

int md5_token::as_int(){
	expect(integer);
	return core::lexical_cast<int>(m_String);
}

float md5_token::as_float(){
	if(m_Tag == integer){
		return core::lexical_cast<float>(m_String);
	}else{
		expect(real);
		return core::lexical_cast<float>(m_String);
	}
}

void md5_token::expect(md5_tags a_Tag){
	if(m_Tag != a_Tag){
		throw md5_token_exception(m_Tag, a_Tag);
	}
}